package com.example.demo.config;

import com.example.demo.bean.Car;
import com.example.demo.bean.Pet;
import com.example.demo.bean.User;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.*;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Repository;

/**
 * @author 软件工程10班 吕俊铭
 * @create 2021-07-29 11:43
 * Description:
 */
//告诉Springboot这是一个配置类，跟spring的配置文件差不多
@Import({User.class})
@Configuration
@ImportResource("classpath:beans.xml")

public class MyConfig {
    //给容器中添加组件，方法名是组件的id，返回类型是组件的class，返回值就是容器的实例


    @Bean
    public User user01(){
        return new User("Zhangsan",18,pet01());
    }
     @Bean("tom")
    public Pet pet01(){
        return new Pet("Tomcat",123);
    }
}
